package com.ruoyi.report.service.impl;

import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.report.domain.ReportProfessional;
import com.ruoyi.report.mapper.ReportProfessionalMapper;
import com.ruoyi.report.service.IReportProfessionalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.DecimalFormat;
import java.util.List;

@Service
public class ReportProfessionalServiceImpl implements IReportProfessionalService {

    @Autowired
    private ReportProfessionalMapper reportProfessionalMapper;

    @Override
    public List<ReportProfessional> selectReportProfessionalList(ReportProfessional reportProfessional) {
        List<ReportProfessional> reportProfessionalList = reportProfessionalMapper.selectReportProfessionalList(reportProfessional);
        for(ReportProfessional professional : reportProfessionalList) {
            double score4 = StringUtils.isEmpty(professional.getScore4()) ? 0 : Double.parseDouble(professional.getScore4());
            double score13 = StringUtils.isEmpty(professional.getScore13()) ? 0 : Double.parseDouble(professional.getScore13());
            double score = score4 * 0.8 + score13 * 0.2;
            DecimalFormat decimalFormat = new DecimalFormat("######0.00");
            professional.setScore(decimalFormat.format(score));
        }
        return reportProfessionalList;
    }
}
